
from bson.son import SON
from local.processor import *
from conf import *
from en2zh import *
from mongo_util import *
from feature import platform2text_col
#  pip install -i https://pypi.tuna.tsinghua.edu.cn/simple streamlit

# {"item_type":"wenzhen"} 丁香  有年龄
# {"url_type":"wenzhen"} 好大夫
# {"url_type": "disease"} 春雨
url = get_mongo_url(username,password,ip,port,dbname)
colllection = 'search_items'
#search_item = new_client(url, dbname,colllection)


def download_and_save(url,dbname, colllection , query_dict, file_name):
    """
    下载然后保存collection 为pk
    :param url:
    :param dbname:
    :param colllection:
    :param query_dict:
    :param file_name:
    :return:
    """
    res = download_collection(url,dbname, colllection , query_dict)
    save_var_cache(res, file_name)

def run():
    """
    下载问诊数据
    :return:
    """
    for k in plat2query:
        query_dict = plat2query[k]
        file_name =  f"wenzhen/{k}.pk"
        download_and_save(query_dict, file_name)
